package com.ruoyi.custom.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.custom.dto.LoginDTO;
import com.ruoyi.custom.service.IUserService;
import com.ruoyi.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@EnableDiscoveryClient
@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    private IUserService userService;

    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    @RequestMapping("/register")
    public R register(String name, String password) {
        SysUser user = new SysUser();
        user.setPassword(password);
        userService.register(user);
        return R.ok("注册成功");
    }

    @PostMapping("/login")
    public R login( @RequestBody LoginDTO loginDTO) {
        System.out.println(loginDTO.getPhoneNumber()+"+"+loginDTO.getCode());
        return R.ok(userService.login(loginDTO.getPhoneNumber(),loginDTO.getCode()));
    }




}
